import { EntityRepository, Repository } from "typeorm";
import { UserEntity } from "./user.entity";

/**
 * @Description: 自定义存储库，这种方法已经弃用，现在 NestJS 推荐使用数据访问对象（Data Access Object，DAO）来处理实体的持久化和查询
 * @author zhaojiuyi
 * @date 2023/4/9
 */
@EntityRepository(UserEntity)
export class UserRepository extends Repository<UserEntity> {

  async getUserByName(username: string): Promise<UserEntity> {
    return await this.findOne({
      where: { username }
    });
  }
}


